<template>
  <div class="app-container">
    <el-form :model="queryParams" size="small" :inline="true">
      <el-form-item>
        <el-cascader
          placeholder="团队名称"
          :options="options"
          filterable
        ></el-cascader>
      </el-form-item>
      <el-form-item>
        <el-cascader
          placeholder="报名渠道名称"
          :options="options"
          filterable
        ></el-cascader>
      </el-form-item>
      <el-form-item>
        <el-input
          placeholder="选手号/姓名/手机号/证件号"
          style="width: 220px"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:role:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:role:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:role:remove']"
          >删除</el-button
        >
      </el-col>

      <el-col :span="1.5">
        <el-button type="danger" plain size="mini" :disabled="multiple"
          >批量取消</el-button
        >
      </el-col>

      <el-col :span="1.5">
        <el-button type="primary" plain size="mini">导出报名选手</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button type="primary" plain size="mini">导出参赛选手</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button type="primary" plain size="mini">导入报名选手</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button type="danger" plain size="mini" :disabled="multiple"
          >批量清空</el-button
        >
      </el-col>

      <el-col :span="1.5">
        <el-button type="danger" plain size="mini" :disabled="multiple"
          >清空配号</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table :data="personalList" style="width: 100%">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="Id" type="index" align="center" width="100" />
      <el-table-column prop="item" label="组别" align="center" width="200">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        align="center"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="playerId"
        label="参赛号"
        align="center"
        width="100"
      >
      </el-table-column>
      <el-table-column prop="sex" label="性别" align="center" width="100">
      </el-table-column>
      <el-table-column prop="phone" label="手机号" align="center" width="100">
      </el-table-column>
      <el-table-column prop="cardId" label="证件号" align="center" width="100">
      </el-table-column>
      <el-table-column prop="status" label="状态" align="center" width="200">
      </el-table-column>
      <el-table-column
        prop="teamName"
        label="所属团队"
        align="center"
        width="100"
      >
      </el-table-column>
      <el-table-column
        prop="channel"
        label="报名渠道"
        align="center"
        width="100"
      >
      </el-table-column>
      <el-table-column prop="date" label="报名日期" align="center" width="200">
      </el-table-column>
      <el-table-column fixed="right" label="操作" align="center" width="200">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleUpdate(scope.row)"
            icon="el-icon-edit"
            size="mini"
            >修改</el-button
          >
          <el-button
            type="text"
            icon="el-icon-document"
            size="mini"
            @click="handleAttachment(scope.row)"
            >附件</el-button
          >
          <el-button
            type="text"
            icon="el-icon-delete"
            size="mini"
            @click="handleLookStatus(scope.row)"
            >报名状态</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="tableData"
    />

    <!-- 添加或修改选手对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="dialogFormVisible"
      append-to-body
      @close="reset"
    >
      <el-row>
        <el-col :span="24">
          <el-form :model="form" :rules="rules" ref="form">
            <el-row>
              <el-col :span="10"
                ><el-form-item
                  label="姓名"
                  prop="name"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="form.name"
                    autocomplete="off"
                    placeholder="请输入姓名"
                  ></el-input> </el-form-item
              ></el-col>
              <el-col :span="10"
                ><el-form-item
                  label="参赛号"
                  prop="playerno"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="form.playerno"
                    autocomplete="off"
                    placeholder="请输入参赛号"
                  ></el-input> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="10"
                ><el-form-item
                  label="性别"
                  prop="sex"
                  :label-width="formLabelWidth"
                >
                  <el-radio v-model="form.sex" label="1">男</el-radio>
                  <el-radio v-model="form.sex" label="2">女</el-radio>
                </el-form-item></el-col
              >
              <el-col :span="10"
                ><el-form-item label="年龄" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.age"
                    autocomplete="off"
                    placeholder="请输入年龄"
                  ></el-input> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="10"
                ><el-form-item
                  label="手机号"
                  prop="phone"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="form.phone"
                    autocomplete="off"
                    placeholder="请输入手机号"
                  ></el-input> </el-form-item
              ></el-col>
              <el-col :span="10"
                ><el-form-item
                  label="身份证号"
                  prop="certno"
                  :label-width="formLabelWidth"
                >
                  <el-input
                    v-model="form.certno"
                    autocomplete="off"
                    placeholder="请输入身份证号"
                  ></el-input> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="10"
                ><el-form-item
                  label="组别"
                  prop="subject"
                  :label-width="formLabelWidth"
                >
                  <el-select v-model="form.subject" placeholder="组别">
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select> </el-form-item
              ></el-col>
              <el-col :span="10"
                ><el-form-item label="团队名" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.team"
                    autocomplete="off"
                    placeholder="请输入团队名"
                  ></el-input> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="10"
                ><el-form-item label="护照号" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.passport"
                    autocomplete="off"
                    placeholder="请输入护照号"
                  ></el-input> </el-form-item
              ></el-col>
              <el-col :span="10"
                ><el-form-item label="赛服尺码" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.matchsize"
                    autocomplete="off"
                    placeholder="请输入尺码"
                  ></el-input> </el-form-item
              ></el-col> </el-row
            ><el-row>
              <el-col :span="10"
                ><el-form-item label="国籍" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.nationality"
                    autocomplete="off"
                    placeholder="请输入国籍"
                  ></el-input> </el-form-item
              ></el-col>
              <el-col :span="10"
                ><el-form-item label="籍贯" :label-width="formLabelWidth">
                  <el-input
                    v-model="form.nativeplace"
                    autocomplete="off"
                    placeholder="请输入籍贯"
                  ></el-input> </el-form-item
              ></el-col>
            </el-row>
          </el-form>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm('form')">取 消</el-button>
        <el-button type="primary" @click="submitForm('form')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  dicts: ["sys_normal_disable", "sys_user_sex"],
  methods: {
    handleAdd() {
      this.dialogFormVisible = true;
      this.title = "新增选手";
    },
    handleUpdate(row) {
      this.dialogFormVisible = true;
      this.title = "编辑选手";
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    reset() {
      this.form = {};
    },
    submitForm(formName) {
      this.$refs[formName].validate((isOK) => {
        if (valid) {
          alert("submit!");
          this.dialogFormVisible = false;
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.dialogFormVisible = false;
    },
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 是否显示弹出层
      dialogFormVisible: false,
      // 弹出层标题
      title: "",
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: undefined,
        url: undefined,
        status: undefined,
        createTime: "",
      },
      formLabelWidth: "120px",
      personalList: [
        // {
        //   date: "2023-06-03 08:30:00",
        //   title: "2023超级飞侠亲子乐运会欢乐赛深圳站",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-04-16 08:00:00",
        //   title: "2023杭州湘湖半程马拉松",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-06-03 08:30:00",
        //   title: "2023超级飞侠亲子乐运会欢乐赛深圳站",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-04-16 07:30:00",
        //   title: "中国银行2023武汉马拉松",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-06-03 08:30:00",
        //   title: "2023超级飞侠亲子乐运会欢乐赛深圳站",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-06-03 08:30:00",
        //   title: "2023超级飞侠亲子乐运会欢乐赛深圳站",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
        // {
        //   date: "2023-06-03 08:30:00",
        //   title: "2023超级飞侠亲子乐运会欢乐赛深圳站",
        //   image:
        //     "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        // },
      ],
      total: 50,
      // 表单校验
      rules: {
        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        playerno: [
          { required: true, message: "请输入参赛号", trigger: "blur" },
        ],
        sex: [{ required: true, message: "请选择性别", trigger: "blur" }],
        phone: [
          { required: true, message: "请输入手机号", trigger: "blur" },
          { len: 11, message: "长度为11", trigger: "blur" },
        ],
        certno: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
          { len: 18, message: "长度为18", trigger: "blur" },
        ],
        subject: [{ required: true, message: "请选择组别", trigger: "blur" }],
      },
    };
  },
};
</script>
